{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import swcloader\n",
    "tree =swcloader.NeuronTree(\"033.swc\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<swcloader.NeuronTree object at 0x00000283F59DF400>\n"
     ]
    }
   ],
   "source": [
    "print(tree)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'getEdges', 'getGraph', 'getSubGraph', 'print', 'printChildren', 'printEdges']\n"
     ]
    }
   ],
   "source": [
    "print(dir(swcloader.NeuronTree))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[128.43401156685712, 69.82902687342383, 60.46446799587206, 6.757271046904696, 110.50384442039578, 675.8742305925058, 311.3328284459514, 780.7522121741202, 11.492355003350013, 255.62873217147003, 186.9559301618928, 115.00519267817137, 50.87922979722767, 172.38218053517906, 532.1070653761552, 646.178097043595, 339.6918152672815, 749.5700398780646, 373.91760009215767, 290.6198311751, 135.53161792529082, 86.10028285797772, 9.937201773038955, 28.018026177619795, 514.0829658441179, 146.6450102663322, 621.1504562471584, 38.52265386543346, 545.4073641345595, 1079.0704623049246, 963.8539548648232, 192.6942768492423, 13.657007233578383, 65.09811065345365, 59.99513222283745, 30.616636127552294, 501.46473460436493, 1382.5275684264802, 38.44451767242429, 422.82264106189643, 777.203292645667, 483.7439824492007, 42.4167064601614, 24.2685199724773, 10.360273373225827, 611.5463713528737, 1583.932078979636, 49.20864840668767, 334.1837218118546, 188.9193513019641, 912.8491899966352, 118.8643377028334, 13.156231468579406, 713.7308661325162, 11.676240747210683, 188.49549187672676]\n"
     ]
    }
   ],
   "source": [
    "import swcloader\n",
    "\n",
    "def distance(p1, p2):\n",
    "    return ((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2 + (p1.z - p2.z) ** 2) ** 0.5\n",
    "\n",
    "edge_length=[]\n",
    "for edge in tree.edges:\n",
    "    edge_length_tem=0\n",
    "    for i in range(0,(len(edge)-1)):\n",
    "#     for point in edge:\n",
    "        p1=edge[i]\n",
    "        p2=edge[i+1]\n",
    "        edge_length_tem+=distance(p1,p2)\n",
    "    edge_length.append(edge_length_tem)\n",
    "\n",
    "print(edge_length)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
